/*
 * To change this license header, choose License Headers in Project Properties.
 * To change this template file, choose Tools | Templates
 * and open the template in the editor.
 */

package view;

import core.DirectoryItem;
import core.Drive;
import core.IconProvider;
import java.awt.Component;
import java.io.File;
import javax.swing.JTable;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableColumn;

/**
 *
 * @author Alex
 */
public class TableDetailView extends TableView {
    public TableDetailView(File item, Boolean isFocus)
    {
        super(item, isFocus);
        TableColumn col =  this.getColumnModel().getColumn(0);
        col.setCellRenderer(new TDetailCellRender());
    }
}

/*
 *Class TDetailCellRender
 */
class TDetailCellRender extends  DefaultTableCellRenderer
{
    @Override
    public Component getTableCellRendererComponent(JTable table, Object value,
            boolean isSelected, boolean hasFocus, int row, int column)
    {
        super.getTableCellRendererComponent(table, value, isSelected, hasFocus, row, column);
        //FileSystemView fsv = FileSystemView.getFileSystemView();

        if (column != 0)
            return this;

         if (value instanceof RowParentFolder)
            {
                RowParentFolder temp = (RowParentFolder)value;
                this.setIcon(temp.getIcon());
                this.setText(temp.getName());
                return this;
            }

        if (value instanceof File)
        {
            File f = (File)value;
            if (f.isDirectory())                
                this.setText('[' + DirectoryItem.getNameofFile(f) + ']');
            else if (DirectoryItem.isPartiton(f))            
                this.setText(Drive.getNameOfVolume(f));            
            else
                this.setText(DirectoryItem.getNameofFile(f));
            
            this.setIcon(IconProvider.getIcon(f));            
        }

        return this;
    }
}
